package org.gap.wizards.combat;

import org.gap.wizards.creature.Creature;
import org.gap.wizards.creature.Creature.Attribute;
import org.gap.wizards.pc.Skill;
import org.gap.wizards.pc.Skilled;
import org.gap.wizards.pc.skills.Challenge;
import org.gap.wizards.pc.skills.ResultType;

public class MeleeAttackChallenge implements Challenge {

	private final Creature attackee;
	private final Skilled attacker;
	private final Attack attack;

	public MeleeAttackChallenge(Creature attackee, Skilled attacker, Attack attack) {
		this.attackee = attackee;
		this.attacker = attacker;
		this.attack = attack;
	}

	@Override
	public ResultType perform() {
		Skill skill = attacker.getSkill(attack.desiredSkillName());
		int modifier = attackee.getAttribute(Attribute.HitModifier);
		return skill.rollWithModifier(modifier);
	}
}
